#include <stdio.h>
#include "link.h"

int main(int argc, const char *argv[])
{
    data_t buf;
    link_t *p;
    p = create_link();

    buf = 250;
    printf("初始化链表完成：\n");
    for(buf = 8; buf >=0; buf--) {
        ins_head_link(p, &buf);
    }
    print_link(p);


    printf("按位置插入数据：3, 400\n");
    ins_index_link(p, 3, 400);
    print_link(p);


    printf("从链表头删除数据：\n");
    del_head_link(p);
    print_link(p);
    del_head_link(p);
    print_link(p);

    printf("删除指定数据的节点：\n");
    del_link_by_data(p, 5);
    print_link(p);

    printf("删除指定位置的节点：\n");
    del_link_by_index(p, 4);
    print_link(p);

    /*
    printf("查找链表中的数据6：\n");
    struct linknode *temp;
    data_t fdata;
    fdata = 6;
    temp = locate_link_pre(p, &fdata);
    if(NULL != temp) printf("locate: %d\n", temp->data);
    print_link(p);
    */

}

